package pl.edu.agh.io.fx3.treecreator.disk;

import pl.edu.agh.io.fx3.utils.JDBCInfo;

public class DiskTreeConfig {

	/**
	 * The main directory of Fx3 Virtual File System.
	 */
	public static final String ROOT_DIR = "fx3_vfs";
	/**
	 * The maximum length of folder in VFS.
	 */
	public static final int FOLDER_NAME_LENGTH = 5;
	
	/**
	 * The heading of options related to directory's hierarchy.
	 */
	public static final String HIERARCHY = "[hierarchy]";
	/**
	 * The number of available options for hierarchy.
	 */
	public static final int HIERARCHY_OPTION_NUMBER = 3;
	/**
	 * The keyword which describes maximum files count in one folder.
	 */
	public static final String MAX_FILES = "maxfiles";
	/**
	 * The keyword which describes maximum folders count in one folder.
	 */
	public static final String MAX_FOLDERS = "maxfolders";
	/**
	 * The keyword which describes pathname when VFS is mounted. 
	 */
	public static final String ROOT_PATH = "rootpath";
	
	/**
	 * The heading of options related to JDBC configuration.
	 */
	public static final String JDBC = "[jdbc]";
	/**
	 * The number of available options for JDBC.
	 */
	public static final int JDBC_OPTION_NUMBER = 4;
	/**
	 * The keyword which describes user's name in database.
	 */
	public static final String USERNAME = "username";
	/**
	 * The keyword which describes user's password in database.
	 */
	public static final String PASSWORD = "password";
	/**
	 * The keyword which describes url to database.
	 */
	public static final String URL = "url";
	/**
	 * The keyword which describes driver to database. 
	 */
	public static final String DRIVER = "driver";
	
	private static final String DEFAULT_ROOT_PATH = "";
	private static final int DEFAULT_MAX_FILES = 1000;
	private static final int DEFAULT_MAX_FOLDERS = 25;
	
	private static final String DEFAULT_JDBC_DRIVER = "org.sqlite.JDBC";
	private static final String DEFAULT_JDBC_URL = "jdbc:sqlite:vfs.db";
	private static final String DEFAULT_JDBC_USERNAME = "postgres";
	private static final String DEFAULT_JDBC_PASSWORD = "postgres";
	
	private String rootPath;
	private int maxFiles;
	private int maxFolders;
	
	private JDBCInfo jdbcInfo;
	
	/**
	 * Default constructor which sets default configuration of Disk File System.
	 */
	public DiskTreeConfig() {
		rootPath = DEFAULT_ROOT_PATH;
		maxFiles = DEFAULT_MAX_FILES;
		maxFolders = DEFAULT_MAX_FOLDERS;
		
		jdbcInfo = new JDBCInfo(DEFAULT_JDBC_DRIVER, DEFAULT_JDBC_URL, DEFAULT_JDBC_USERNAME, DEFAULT_JDBC_PASSWORD);
	}

	/**
	 * Gets maximum number of files in one folder.
	 * 
	 * @return The maximum number of files.
	 */
	public int getMaxFiles() {
		return maxFiles;
	}
	
	/**
	 * Gets maximum number of folders in one folder.
	 * 
	 * @return The maximum number of folders.
	 */
	public int getMaxFolders() {
		return maxFolders;
	}
	
	/**
	 * Gets object which store information on JDBC.
	 * 
	 * @return The object which store information on JDBC.
	 */
	public JDBCInfo getJdbcInfo() {
		return jdbcInfo;
	}
	
	/**
	 * Gets path where VFS is mounted.
	 * 
	 * @return Path where VFS is mounted.
	 */
	public String getRootPath() {
		return rootPath;
	}
	
	/**
	 * Sets object which store information on JDBC.
	 * 
	 * @param jdbcInfo The object which store information on JDBC.
	 */
	public void setJdbcInfo(JDBCInfo jdbcInfo) {
		this.jdbcInfo = jdbcInfo;
	}

	/**
	 * Sets maximum number of files in one folder.
	 * 
	 * @param maxFiles The maximum number of files in one folder.
	 */
	public void setMaxFiles(int maxFiles) {
		this.maxFiles = maxFiles;
	}
	
	/**
	 * Sets maximum number of folders in one folder.
	 * 
	 * @param maxFolders The maximum number of folders in one folder.
	 */
	public void setMaxFolders(int maxFolders) {
		this.maxFolders = maxFolders;
	}

	/**
	 * Sets path where VFS is mounted.
	 * 
	 * @param rootPath Path where VFS is mounted.
	 */
	public void setRootPath(String rootPath) {
		this.rootPath = rootPath;
	}
}
